home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1995-06-22 | 7.4 KB | 324 lines |
- >$.Wimp.UserDrag
- *********************************
- * Dragging the WIMP *
- * written by Adrian Philip Look *
- * 5th October 1988 *
- *********************************
- sys_reporterror
- sys_variables
- sys_startup
- program_startup
- sys_reporterror
- "Wimp_ForceRedraw",-1,0,0,1280,1024
- quit%=
- "Wimp_Poll",mask%,block%
- reason%
- program_wimppoll(reason%)
- quit%
- sys_reporterror
- wimp_closedown
- $;" at line ";
- sys_startup
- ("Close")
- "OS_CLI","Print $.Wimp.WimpFont"
- "OS_CLI","Print $.Wimp.Palette"
- version%=
- wimp_initialise
- 0,143:
- ("fx 25 0")
- sys_variables
- block% &4000
- icondata% 11
- bodgeit%=
- mask%=0
- sys_quit
- quit%=
- wimp_closedown
- sys_windowinfo(block%)
- x0%=block%!4
- y0%=block%!8
- x1%=block%!12
- y1%=block%!16
- scx%=block%!20
- scy%=block%!24
- pos%=block%!28
- =Kbx%=x0%-scx%:by%=y1%-scy% :
- all drawing should be relative to bx%,by%
- WINDOWS
- AM-------------------------------------------------------------------------
- sys_windowcolours(tfg%,tbg%,wfg%,wbg%,so%,sin%,hi%)
- windowtitlefg%=tfg%
- windowtitlebg%=tbg%
- windowworkfg%=wfg%
- windowworkbg%=wbg%
- scrollout%=so%
- scrollin%=sin%
- highlight%=hi%
- sys_windowextent(sx%,sy%,sizex%,sizey%)
- scrx%=sx%
- scry%=sy%
- wx0%=0
- wy0%=-sizey%
- wx1%=sizex%
- wy1%=0
- sys_windowflags(tb,mv,vts,hts,wmr,pan,oma,boq,sra,srd)
- flags%
- -tb
- flags%=flags%
- &01 :
- title bar
- -mv
- flags%=flags%
- &02 :
- movable
- -vts
- flags%=flags%
- &04 :
- vertical scroll bar
- -hts
- flags%=flags%
- &08 :
- horzintal scroll bar
- -wmr
- flags%=flags%
- &10 :
- can be redrawn by AWM
- -pan
- flags%=flags%
- &20 :
- window is a pane
- -oma
- flags%=flags%
- &40 :
- window can go outside main area
- -boq
- flags%=flags%
- &80 :
- back and quit box
- -sra
- flags%=flags%
- &100 :
- scroll-rqst returned (auto-repeat)
- -srd
- flags%=flags%
- &200 :
- scroll-rqst returned (debounced)
- =flags%
- sys_createwindow(x0%,y0%,x1%,y1%,pos%,iconflags%,wflags%,bt%)
- x,handle%
- block%+=4
- f+block%!0=x0% :
- window screen position
- block%!4=y0%
- block%!8=x1%
- block%!12=y1%
- j+block%!16=scrx% :
- scroll bar position
- block%!20=scry%
- l,block%!24=pos% :
- window stack position
- m&block%!28=wflags% :
- window flags
- n(block%?32=windowtitlefg% :
- colours
- block%?33=windowtitlebg%
- block%?34=windowworkfg%
- block%?35=windowworkbg%
- block%?36=scrollout%
- block%?37=scrollin%
- block%?38=highlight%
- block%?39=0 :
- reserved
- v+block%!40=wx0% :
- work area definition
- block%!44=wy0%
- block%!48=wx1%
- block%!52=wy1%
- z1block%!56=iconflags% :
- title bar icon flags
- {/block%!60=bt%<<12 :
- work area button type
- |0block%!64=0 :
- sprite control block pointer
- block%!68=0 :
- reserved
- x=0
- 11:!(block%+72+x)=icondata%!x:
- x :
- title icon data
- !block%!84=0 :
- no of sprites
- &handle%=
- wimp_createwindow(block%)
- block%-=4:block%!0=handle%
- =handle%
- L------------------------------------------------------------------------
- wimp_initialise
- version%,x%
- "Wimp_Initialise"
- version%
- bodgeit%=(version%<18)
- bodgeit%
- oldfx%(9)
- x%=0
- "OS_Byte",x%+220,2,0
- ,oldfx%(x):
- "OS_Bytes",219,2,0
- ,oldfx%(9)
- =version%
- wimp_createwindow(block%)
- handle%
- "Wimp_CreateWindow",,block%
- handle%
- =handle%
- wimp_deletewindow(handle%)
- !block%=handle%
- "Wimp_DeleteWindow",,block%
- wimp_openwindow(block%)
- "Wimp_OpenWindow",,block%
- wimp_closewindow(handle%)
- !block%=handle%
- "Wimp_CloseWindow",,block%
- wimp_closedown
- bodgeit%
- x%=0
- "OS_Byte",x%+220,oldfx%(x%),0
- "OS_Bytes",219,oldfx%(9),0
- "Wimp_CloseDown"
- 0THE ACTUAL PROGRAM
- THE WIMP IMPLEMENTATION
- M-------------------------------------------------------------------------
- program_startup
- circle(2,2)
- i=0
- 7circle(i,0)=
- (1079)+100 :
- x co-ordinate of circle
- 7circle(i,1)=-
- (823)-100 :
- y co-ordinate of circle
- 0circle(i,2)=
- (50)+50 :
- radius of circle
- present=-1
- drag=
- sys_windowcolours(14,13,7,0,4,13,11)
- sys_windowextent(0,0,1279,1023)
- 1wflags%=
- sys_windowflags(1,1,1,1,0,0,0,1,0,0)
- (iconflags%=&19:$icondata%="DRAGGING"
- Dwindow%=
- sys_createwindow(0,0,1279,1023,-1,iconflags%,wflags%,6)
- wimp_openwindow(block%)
- program_calclimits
- .cx0%=circle(present,0)-circle(present,2)-4
- .cy0%=circle(present,1)-circle(present,2)-4
- .cx1%=circle(present,0)+circle(present,2)+4
- .cy1%=circle(present,1)+circle(present,2)+4
- program_wimppoll(reason%)
- reason%
- 0 :
- drag>0
- program_updatedrag
- 1 :
- program_redrawwindow
- 2 :
- wimp_openwindow(block%)
- 3 :
- wimp_closewindow(!block%)
- 6 :
- program_processbuttons
- 7 : drag=0:
- program_updatedrag :
- drag finished
- program_redrawwindow
- "Wimp_RedrawWindow",,block%
- more
- get the top left-hand corner of the window (bx%,by%) in OS units
- sys_windowinfo(block%)
- more
- plot backwards, so that circle 0 is on the top
- i=2
- 0,10+i :
- different colours
- bx%+circle(i,0),by%+circle(i,1)
- &9D,bx%+circle(i,0)+circle(i,2),by%+circle(i,1)
- "Wimp_GetRectangle",,block%
- more
- program_updatedrag
- x%,y%,b%
- mx%=x%
- my%=y%
- drag
- 5 :
- program_calclimits
- >
- "Wimp_ForceRedraw",window%,cx0%,cy0%,cx1%,cy1%
- & circle(present,0)+=x%-mx%
- & circle(present,1)+=y%-my%
- mx%=x%:my%=y%
-
- program_calclimits
- >
- "Wimp_ForceRedraw",window%,cx0%,cy0%,cx1%,cy1%
- 7 :
- program_calclimits
- >
- "Wimp_ForceRedraw",window%,cx0%,cy0%,cx1%,cy1%
- < x=bx%+circle(present,0):y=by%+circle(present,1)
- # d=
- ((x-x%)^2+(y-y%)^2)
- circle(present,2)=d
- mx%=x%:my%=y%
-
- program_calclimits
- >
- "Wimp_ForceRedraw",window%,cx0%,cy0%,cx1%,cy1%
- program_processbuttons
- (block%!8
- &10)>0
- drag=7 :
- drag with the adjust
- (block%!8
- &40)>0
- drag=5 :
- drag with the select
- <mx%=block%!0:my%=block%!4 :
- get the mouse co-ordinates
- program_intersect
- drag=
- drag>0
- program_initdrag
- program_intersect
- get the top left-hand corner of the window (bx%,by%) in OS units
- block%!0=window%
- "Wimp_GetWindowState",,block%
- sys_windowinfo(block%)
- check for intersection when mouse is at (mx%,my%)
- present=-1
- i=0
- 'x=bx%+circle(i,0):y=by%+circle(i,1)
- ((x-mx%)^2+(y-my%)^2)
- d<=circle(i,2)
- present=i:i=99
- 1=(i=100) :
- i=100 if intersection occurs!!!!
- program_initdrag
- block%!0=window%
- "Wimp_GetWindowState",,block%
- sys_windowinfo(block%)
- program_calclimits
- drag type
- block%!4=drag
- initial box (bounding the circle)
- block%!8=bx%+cx0%
- block%!12=by%+cy0%
- block%!16=bx%+cx1%
- block%!20=by%+cy1%
- parent box (area in which the box may be moved)
- block%!24=x0%
- block%!28=y0%
- block%!32=x1%
- block%!36=y1%
- "Wimp_DragBox",,block%
-